{% extends "dashboard/base.html" %}
{% load i18n %}
{% load materializecss %}
{% load staticfiles %}

{% block title %}
  {% if product_image.pk %}
    {{ product_image.image.name }}
  {% else %}
    {% trans "Add image" %}
  {% endif %} - {{ block.super }}
{% endblock %}

{% block body_class %}body-store body-products{% endblock %}

{% block menu_products_class %}active{% endblock %}

{% block header_menu %}
  {% url "dashboard:product-update" pk=product.pk as url %}
  {% include "dashboard/includes/_back-link.html" with url=url hash="#images" %}
{% endblock %}

{% block breadcrumbs %}
  <ul class="breadcrumbs breadcrumbs--history">
    <li>
      <a href="{% url "dashboard:product-update" pk=product.pk %}#images" class="breadcrumbs--ellipsed-item">
        {{ product }}
      </a>
    </li>
    <li class="back-mobile">
      <a href="{% url "dashboard:product-update" pk=product.pk %}#images" class="breadcrumb">
        <svg data-src="{% static "dashboard/images/arrow_left.svg" %}" fill="#fff" width="20px" height="20px" />
      </a>
    </li>
    {% if product_image.pk %}
      <li>
        <span class="breadcrumbs--ellipsed-item">
          {{ product_image.alt|default:_("No description") }}
        </span>
      </li>
    {% else %}
      <li>
        <span class="hide-on-med-and-down">
          {% trans "Add image" context "Image form breadcrumbs" %}
        </span>
        <span class="hide-on-large-only breadcrumbs--ellipsed-item">
          {% blocktrans trimmed context "Image form breadcrumbs"  %}
            Add image for {{ product }}
          {% endblocktrans %}
        </span>
      </li>
    {% endif %}
  </ul>
{% endblock %}

{% block menu_catalogue_class %} active{% endblock %}

{% block content %}
  <div class="row">
    <div class="col s12 m9">
      <div class="card">
        <form method="post" enctype="multipart/form-data">
          <div class="card-content">
            {% csrf_token %}
            <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#images">
            <div class="row">
              <div class="col s12 m8">
                <div class="row">
                  {{ form.image|materializecss }}
                </div>
                {% if product_image.pk %}
                  <p class="no-margin">
                    {% trans "Pick the most relevant part of the image using the red circle." context "Image form text" %}
                  </p>
                {% endif %}
              </div>
              <div class="col s12 m4">
                {% if show_variants %}
                  <div class="row">
                    {{ form.variants|materializecss }}
                  </div>
                {% endif %}
              </div>
            </div>
            <div class="row">
              {{ form.alt|materializecss }}
            </div>
          </div>
          <div class="card-action right-align">
            {% if product_image.pk %}
              <a href="{% url "dashboard:product-update" pk=product.pk %}#images" class="btn btn-flat">
                {% trans "Cancel" context "Dashboard cancel action" %}
              </a>
              <button type="submit" class="btn waves-effect waves-light">
                {% trans "Update" context "Dashboard update action" %}
              </button>
            {% else %}
              <a href="{% url "dashboard:product-update" pk=product.pk %}#images" class="btn btn-flat">
                {% trans "Cancel" context "Dashboard cancel action" %}
              </a>
              <button type="submit" class="btn waves-effect waves-light">
                {% trans "Create" context "Dashboard create action" %}
              </button>
            {% endif %}
          </div>
        </form>
      </div>
    </div>
    <div class="col s12 m3 help-box"></div>
  </div>
{% endblock %}
